fix(adapter): warn on malformed external-dns resource label#305
Merged
Conversation
The 3 sites parsing the external-dns "resource" label (kind/namespace/name) returned nil on any parse error, conflating "label absent" (expected: no origin) with "label present but malformed" (an anomaly). A malformed label silently dropped the FQDN origin — the card showed no source and there was no way to tell a missing origin from a broken one. Add parseOriginLabel, shared by originRefFromLabel (v1) and originRefV2FromLabel (v2): empty stays silent; a non-empty unparsable label is logged at warn level (internal/log, slog/zap) with the raw value. extractNamespace stays silent — it is paired with originRef* on the same endpoints, so the origin path already logs the anomaly once. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…port
Review follow-ups:
- hoist originRef parsing out of the per-group loop in EndpointStatusToGroups
and EndpointStatusToGroupsV2: the resource label is identical across an
endpoint's groups, so this avoids re-parsing and, for a malformed label,
avoids emitting one warn per group (now one per endpoint).
- import internal/log unaliased ("log") to match the rest of the repo.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pre-existing observability debt (flagged during #291): the three sites in
internal/adapter/endpoint.goparsing the external-dnsresourcelabel (kind/namespace/name) returned nil on any parse error, conflating absent (expected: no origin) with present-but-malformed (an anomaly). A malformed label silently dropped the FQDN origin — the card showed no source, with no way to tell a missing origin from a broken one.Fix
parseOriginLabel(shared byoriginRefFromLabelv1 andoriginRefV2FromLabelv2): empty stays silent; a non-empty unparsable label is logged at warn (internal/log, slog/zap) with the raw value.extractNamespacestays silent — it is paired withoriginRef*on the same endpoints, so the origin path already logs the anomaly once.EndpointStatusToGroupsandEndpointStatusToGroupsV2: the label is identical across an endpoint's groups, so this avoids re-parsing and avoids emitting one warn per group.No behavior change for valid/absent labels; only adds a warn for the malformed-present case.
Test plan
go test -race ./internal/adapter/...,golangci-lintclean🤖 Generated with Claude Code